#pragma once

#if (_MSC_VER == 1700)  
#include <memory>
#else
#include <boost/shared_ptr.hpp>
#endif

#include "Ship.h"
#include "BattleEncoded.h"

class BattleShip;
#if (_MSC_VER == 1700)  
typedef std::shared_ptr<BattleShip> BattleShipPtr;
#else
typedef boost::shared_ptr<BattleShip> BattleShipPtr;
#endif

#define MAX_H 10
#define MAX_V 10

class BattleShip {
private:
	int m_table[MAX_H][MAX_V]; // -1:unknown, 0:no ship, 1:inship
	bool m_hasShip[MAX_SHIP+1];
	int m_left [MAX_H][MAX_V];
	int m_right [MAX_H][MAX_V];
	int m_top [MAX_H][MAX_V];
	int m_bottom [MAX_H][MAX_V];
	int m_maxLength;
public:
	BattleShip();
	~BattleShip();
	BattleEncodedPtr Encode();
	unsigned int EncodeInt32();
	static BattleShipPtr DecodeInt32(unsigned int data);
	BattleShipPtr Clone();
	bool PutShip(ShipPtr _ship);
	bool IsShipInBattle(ShipPtr _ship);
	void SetValue(Point p, bool value);
	ShipPtr FindShip(Point p, Ship::TypeOfShip type);
	bool IsUnkown(Point p);
	bool IsInShip(Point p);
	bool IsExist(Point p, int length);
	bool IsExist(Point p, Ship::Rotation r, int length);
	static bool IsInBattle(Point p);
	float GetReduceCost(Point p);
};